/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package wwcontroluiclient;

import javax.swing.table.AbstractTableModel;
//import wwcontrolserver.WWControlServer;
/**
 *
 * @author Michael Ferry
 */
public class HeaterTableModel extends AbstractTableModel{
    public static final int EnableColumn=3;
    public static final int SetTempCol=1;
    public static final int SetRangeCol=2;
    public static final int IndexCol=0;
    
    private String[] columnNames = {"Digestor", "Set Point (C)", "Set Range (+/- C)", "Control"};
    private Object[][] data = {{new Integer(1),new Double(WWControlUIClient.DefaultTempSetPoint),new Double(WWControlUIClient.DefaultTempSetRange), false},
        {new Integer(2),new Double(WWControlUIClient.DefaultTempSetPoint),new Double(WWControlUIClient.DefaultTempSetRange), false},
        {new Integer(3),new Double(WWControlUIClient.DefaultTempSetPoint),new Double(WWControlUIClient.DefaultTempSetRange), false},
        {new Integer(4),new Double(WWControlUIClient.DefaultTempSetPoint),new Double(WWControlUIClient.DefaultTempSetRange), false}};
        
    public int getColumnCount() {
        return columnNames.length;
    }

    public int getRowCount() {
        return data.length;
    }

    public String getColumnName(int col) {
        return columnNames[col];
    }

    public Object getValueAt(int row, int col) {
        return data[row][col];
    }
    public void setValueAt(Object value, int row, int col) {
        data[row][col] = value;
        fireTableCellUpdated(row, col);
    }
    public void syncValueAt(Object value, int row, int col){
        data[row][col] = value;
        //fireTableDataChanged();
    }
    public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
    }
    public boolean isCellEditable(int row, int col) {
        //Note that the data/cell address is constant,
        //no matter where the cell appears onscreen.
        if (col == IndexCol) {
            return false;
        }
        else if (col == EnableColumn){
            return true;
        }
        else {
            return !(Boolean)getValueAt(row,EnableColumn);
        }
    }
}
